﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VanTaiBLL;
using VanTaiData;
using VanTaiProperty;
namespace Roles
{
    public class SecurityServices
    {
        private static DataTable dtUserPermiss;
        private static clsBusiness_tb_UserPermiss clsUserPermiss = new clsBusiness_tb_UserPermiss();
        public static bool HasPermisstion(string FunctionName, int RolesID,TypeaAudit audit)
        {
            dtUserPermiss = clsUserPermiss.BindGridUserPermiss();
            if (dtUserPermiss != null && dtUserPermiss.Rows.Count > 0)
            {
                foreach (DataRow drUserPermiss in dtUserPermiss.Rows)
                {
                    if ((int)drUserPermiss["RolesID"] == RolesID && drUserPermiss["FunctionName"].ToString() == FunctionName)
                        return Roles.Untils.HasPermisstion(audit, (int)drUserPermiss["PermisstionNumber"]);
                }
            }
            return false;
        }
        public static bool HasPermisstionPage(string FunctionName, int RolesID, bool Is_Page)
        {
            dtUserPermiss = clsUserPermiss.BindGridUserPermiss();
            if (dtUserPermiss != null && dtUserPermiss.Rows.Count > 0)
            {
                foreach (DataRow drUserPermiss in dtUserPermiss.Rows)
                {
                    if ((int)drUserPermiss["RolesID"] == RolesID && drUserPermiss["FunctionName"].ToString() == FunctionName && (bool)drUserPermiss["Is_Page"] == Is_Page)
                        return true;
                }
            }
            return false;
        }
    }
}
